#ifndef LHC_MEMORY_STREAM_H_INCLUDED_
#define LHC_MEMORY_STREAM_H_INCLUDED_

#include "IStream.h"
#include "Macros.h"
#include <vector>

namespace lhcutils
{

class MemoryStream : public IStream
{
public:
	MemoryStream();
	virtual bool CanRead() OVERRIDE;
	virtual bool CanWrite() OVERRIDE;
	virtual bool CanSeek() OVERRIDE;
	virtual boost::int64_t GetPosition() OVERRIDE;
	virtual void SetPosition(boost::int64_t newPosition, SeekOrigin::Value origin) OVERRIDE;
	virtual void Flush() OVERRIDE;
	virtual size_t Read(void* buffer, size_t count) OVERRIDE;
	virtual void Write(const void* buffer, size_t count) OVERRIDE;
	virtual void Close() OVERRIDE;
	virtual ~MemoryStream();

private:
	std::vector<uint8_t> m_buffer;
	boost::int64_t m_position;
};

}

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
